#ifndef TRACKER_H
#define TRACKER_H

#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/calib3d.hpp>
#include <vector>
#include <iostream>

using namespace cv;
using namespace std;

const double akaze_thresh = 3e-4;   // AKAZE detection threshold set to locate about 1000 keypoints
const double ransac_thresh = 2.5f;  // RANSAC inlier threshold
const double nn_match_ratio = 0.8f; // Nearest-neighbour matching ratio
const int bb_min_inliers = 10;		// Minimal number of inliers to draw bounding box
const int stats_update_period = 10; // On-screen statistics are updated every 10 frames

short doubleToShort(double d);

class Tracker
{
public:
	Tracker(Ptr<Feature2D> _detector, Ptr<DescriptorMatcher> _matcher) : detector(_detector),
		matcher(_matcher)
	{
	}
	void setFirstFrame(const Mat frame, Rect box);
	Mat process(const Mat frame);
	Ptr<Feature2D> getDetector()
	{
		return detector;
	}

protected:
	Ptr<Feature2D> detector;
	Ptr<DescriptorMatcher> matcher;
	Mat first_desc;
	vector<KeyPoint> first_kp;
	vector<Point2f> object_bb;

private:
	void drawBoundingBox(Mat image, vector<Point2f> bb);
	vector<Point2f> Points(vector<KeyPoint> keypoints);
};

#endif //TRACKER_H